package com.element.oauth2.server.service;

import com.element.oauth2.model.entity.AuthUserE;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsPasswordService;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import java.util.Map;

/**
 * @auther WuJun.Zhang
 * @date 2022/2/18 下午9:03
 */
public interface IAuthUserDetailsService extends UserDetailsService, UserDetailsPasswordService {

    /**
     * 根据用户名称查询用户信息
     *
     * @param userName 用户名称
     * @return UserDetails
     * @throws UsernameNotFoundException 用户不存在异常
     */
    @Override
    AuthUserE loadUserByUsername(String userName) throws UsernameNotFoundException;

    /**
     * 更新用户密码
     *
     * @param user        用户数据
     * @param newPassword 新密码
     * @return 结果
     */
    @Override
    AuthUserE updatePassword(UserDetails user, String newPassword);

    /**
     * 根据参数查询用户信息
     *
     * @param params 参数
     * @return AuthUserE
     * @throws UsernameNotFoundException 异常
     */
    AuthUserE loadUserByParams(Map<String, String> params) throws UsernameNotFoundException;
}